%% ����ɸѡ��׼
index=sort(dp1(:));%dp1�Ǹ���fingerprint-weight�õ���Ȩ�ؾ�����һ���������ҵ������Ǹ�������ɾ������Ϊ�����������ӡ�
a=max(index);%�ҵ�������ġ�
index(index==a)=[];%ɾ��
a=max(index);%��������ֵ
b=[98:-1:0];%���涨�����͹��˷�Χ
for iii=1:length(b)
spacity(iii)=prctile(index,b(iii));%Ѱ�Ҷ�Ӧ�İٷ�λ����������һ��ɸѡ��׼
end
%% ׼����������
lengthspa=length(spacity);%�趨ѭ������
all_mat_or=cat(3,all_default_se1,all_default_se2);%�㶨ԭʼ���󣬽�ǰ������ϲ���һ����ά����ǰ��ά�Ǿ��󣬵���ά�Ǳ�����
[x,y,z]=size(all_mat_or);%��Ҫ�õ���ά�ȳ���

all_mat_or=reshape(all_mat_or,[x*y,z]);
all_mat_or=all_mat_or';%��FC������ƽ����ά�����ɶ�ά����
 
group1_number=size(all_default_se1,3);%��һ�������

for ii=1:lengthspa
        dp2=dp1;
        dp2(dp2<spacity(ii))=0; 
        dp2(dp2~=0)=1;
        dp3=dp2(:)';
        mask_index1(ii,:)=dp3;
        dp4=repmat(dp3,z,1);
        all_mat(:,:,ii)=dp4.*all_mat_or;
end 
all_mat1=all_mat(1:0.5*z,:,:);
all_mat2=all_mat(0.5*z+1:end,:,:);
%%
h=waitbar(0,'wait');
for j=1:lengthspa
    %��ȡ����Ӧ�ܶȵľ���Ȼ����й�һ��
     all_mat_1= all_mat1(:,:,j);
     [all_mat_1 CP]=mapminmax(all_mat_1, -1,1);
     all_mat_2= all_mat2(:,:,j);
     [all_mat_2 CP]=mapminmax(all_mat_2, -1,1);
     
     %������ָ����ȷ����Pֵ
     [Accuracy,p_Accuracy]=fingerprinting(all_mat_1,all_mat_2,10,group1_number);
     AB_acc_baniry(j)=Accuracy(1);
     AB_p_vlaue(j)=p_Accuracy;
     waitbar(j/lengthspa,h,[num2str(j),'/',num2str(lengthspa)])
     clear all_mat_1 all_mat_2
end
close(h)
b=100-b;
plot(b,AB_acc_baniry)

